<include file="public@header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<div class="nav nav-tabs">
			<h4>百度统计</h4>
		</div>
	</div>
	<div>
		<div id="container" style="min-width: 310px; max-width: 600px; height: 400px; margin: 0 auto"></div>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
	<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
	<script src="https://img.hcharts.cn/highcharts/modules/drilldown.js"></script>
	<script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script>
<script>
    $(function () {
        chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'pie',
                events: {
                    load: getdata // 图表加载完毕后执行的回调函数
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        format: '<b>{point.name}</b>: {point.y}条',
                    }
                }
            },
            title: {
            },
            series: [{
                name: '总数据'
            }]
        });
        function getdata(){
            $.ajax({
                url:'{:url("getdatatobaidu")}',
				data:{start_time:$('#start_time').val(),end_time:$('#end_time').val()},
                dataType:'json',
                type:'post',
                success:function(data) {
                        //具体的参数详见：https://api.hcharts.cn/highcharts#Series.addPoint
					for(var i in data) {
					    if(i == 'title') {
                            chart.setTitle({
								text : '百度推广数据:共' + data[i]['total'] + '条'
							});
						}
                        chart.series[0].addPoint({
                            id :data[i].id,
                            name:data[i].domain,
                            y:data[i].scount,
                        }, true);
					}
//                    console.log(data)
                }
            });
        }
    });
</script>
</body>
</html>